<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h2>0</h2>
    <button onclick="plus()">+</button>
    <button onclick="less()">-</button>
    <script>
      // 需求1
      const h2 = document.querySelector("h2");
      let num = 0;
      function plus() {
        num++;
        h2.innerText = num;
      }
      // 需求2
      function less() {
        num--;
        h2.innerText = num;
      }
    </script>
  </body>
</html>
